package org.tps.project.controllers;




import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import Project.ejb1.entities.Drh;
import Project.ejb1.services.DrhServiceLocal;

@ManagedBean
@SessionScoped
public class DrhController {

	@EJB
	private DrhServiceLocal drhService;

	private Drh connectedUser = new Drh();

	public String connect() {
		java.util.List<Drh> drhs = drhService.findAll();

		for (Drh drh : drhs) {
			if (drh.getLogin().equals(this.connectedUser.getLogin())
					&& drh.getMotDePasse().equals(this.connectedUser.getMotDePasse())) {
				return "Missionindex.xhtml?faces-redirect=true";
			}
		}
		return null;
	}

	public Drh getConnectedUser() {
		return connectedUser;
	}

	public void setConnectedUser(Drh connectedUser) {
		this.connectedUser = connectedUser;
	}

}